package cn.zs.supply.common.utils;


import java.util.HashMap;

/**
 * 接口日志
 */
public class LogParameter {

	public static final String interfaceKind="interfaceKind";
	public static final String platform="platform";
	public static final String keyValue="keyValue";
	public static final String reqSn="reqSn";
	public static final String isform="isform";
	public static final String isSuccess="isSuccess";
	public static final String returnUrl="returnUrl";
	public static final String requestUrl="requestUrl";
	public static final String requestContent="requestContent";
	public static final String resultContent="resultContent";
	public static final String requestExpressly="requestExpressly";
	public static final String returnExpressly="returnExpressly";
	public static final String orderNo="orderNo";	
	
	//解决问题：日志中序列号与实际交互无关	
	public static final String reqSerialNo="reqSerialNo";

	private static ThreadLocal<HashMap<String, Object>> parameters = new ThreadLocal<HashMap<String, Object>>() {
		@Override
		protected HashMap<String, Object> initialValue() {
			return new HashMap<String, Object>();
		}
	};
	
	public static void setOrderNo(String value){
		parameters.get().put(orderNo, value);
	}
	public static void setInterfaceKind(Integer value){
		parameters.get().put(interfaceKind, value);
	}
	public static void setPlatform(Integer value){
		parameters.get().put(platform, value);
	}
	public static void setKeyValue(String value){
		parameters.get().put(keyValue, value);
	}
	public static void setIsform(Integer value){
		parameters.get().put(isform, value);
	}
	public static void setIsSuccess(Integer value){
		parameters.get().put(isSuccess, value);
	}
	public static void setRequestContent(String value){
		parameters.get().put(requestContent, value);
	}
	public static void setResultContent(String value){
		parameters.get().put(resultContent, value);
	}
	public static void setReqSn(String value){
		parameters.get().put(reqSn, value);
	}
	public static void setRequestExpressly(String value){
		parameters.get().put(requestExpressly, value);
	}
	public static void setReturnExpressly(String value){
		parameters.get().put(returnExpressly, value);
	}
	public static void setReturnUrl(String value){
		parameters.get().put(returnUrl, value);
	}
	public static void setRequestUrl(String value){
		parameters.get().put(requestUrl, value);
	}
	public static Object get(String key){
		return parameters.get().get(key);
	}

	public static String getString(String key){
		Object objValue = get(key);
		return objValue != null ? (String)objValue : "";
	}
	public static Integer getInteger(String key){
		String strValue = String.valueOf(get(key));
		return strValue != null && !"null".equals(strValue) ? Integer.valueOf(strValue) : null;
	}
	public static Short getShort(String key){
		String strValue = String.valueOf(get(key));
		return strValue != null && !"null".equals(strValue) ? Short.valueOf(strValue) : null;
	}
	public static boolean containsKey(String key){
		return parameters.get().containsKey(key);
	}

	public static boolean containsValue(Object value){
		return parameters.get().containsValue(value);
	}

	public static void clear(){
		parameters.get().clear();
	}

}
